package com.ymatou.iapi.liveseller.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.liveseller.parameter.RemoveSellerLiveBean;
import com.ymatou.iapi.liveseller.service.RemoveSellerLiveCall;
import com.ymatou.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.database.model.LiveRoom;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
/**
*买手（主播）删除直播
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_RemoveSellerLive{
	private static RemoveSellerLiveBean removesellerliveBean;
	private static RemoveSellerLiveCall removesellerliveCall;
	private static LiveRoomWapper liveRoomWapper;
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("买手（主播）删除直播");
	}

	@Before
	public void caseUp() {
		removesellerliveBean=new RemoveSellerLiveBean();
		removesellerliveCall=new RemoveSellerLiveCall();
		liveRoomWapper=new LiveRoomWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(removesellerliveCall.getOpurl());
		liveRoomWapper=null;
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_RemoveSellerLive_001() {
		Logger.start(true,"status7买手（主播）删除直播成功");
		try {
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
			liveRoomWapper.updateLiveRoomPushStatus(createlive.getId(), 7);
			removesellerliveBean.setLiveId(createlive.getId());
			removesellerliveBean.setUserId(createlive.getUserId());
			removesellerliveCall.setData(removesellerliveBean);
			removesellerliveCall.callService();			
			Logger.verifyEquals("200", removesellerliveCall.getString("Code"), "验证Code");
			Logger.verifyEquals(true, removesellerliveCall.getSuccess(), "验证Code");
			LiveRoom dblive = liveRoomWapper.selectLiveRoomById(createlive.getId());
			Logger.verifyEquals(-1, dblive.getAction(), "验证status");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_RemoveSellerLive_002() {
		Logger.start(true,"不输入liveid失败");
		try {
//			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
//			liveRoomWapper.updateLiveRoomPushStatus(createlive.getId(), 7);
//			removesellerliveBean.setLiveId(createlive.getId());
			removesellerliveBean.setUserId(1);
			removesellerliveCall.setData(removesellerliveBean);
			removesellerliveCall.callService();			
			Logger.verifyEquals("400", removesellerliveCall.getString("Code"), "验证Code");
			Logger.verifyEquals("直播Id参数错误", removesellerliveCall.getString("Msg"), "验证Msg");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_RemoveSellerLive_003() {
		Logger.start(true,"不输入Userid失败");
		try {
			removesellerliveBean.setLiveId(1);
			removesellerliveCall.setData(removesellerliveBean);
			removesellerliveCall.callService();			
			Logger.verifyEquals("400", removesellerliveCall.getString("Code"), "验证Code");
			Logger.verifyEquals("买手Id参数错误", removesellerliveCall.getString("Msg"), "验证Msg");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RemoveSellerLive_004() {
		Logger.start(true,"liveid和userid不匹配失败");
		try {
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
			liveRoomWapper.updateLiveRoomPushStatus(createlive.getId(), 9);
			removesellerliveBean.setLiveId(createlive.getId());
			removesellerliveBean.setUserId(createlive.getUserId()+1);
			removesellerliveCall.setData(removesellerliveBean);
			removesellerliveCall.callService();			
			Logger.verifyEquals("200", removesellerliveCall.getString("Code"), "验证Code");
			Logger.verifyEquals(false, removesellerliveCall.getSuccess(), "验证Code");
			LiveRoom dblive = liveRoomWapper.selectLiveRoomById(createlive.getId());
			Logger.verifyEquals(0, dblive.getAction(), "验证status");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RemoveSellerLive_005() {
		Logger.start(true,"status8已关闭直播运营端删除成功");
		try {
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
			LiveRoomCallService.CloseSellerLive(createlive.getId(), createlive.getUserId(), 8);
			removesellerliveBean.setLiveId(createlive.getId());
			removesellerliveBean.setUserId(createlive.getUserId());
			removesellerliveCall.setData(removesellerliveBean);
			removesellerliveCall.callService();			
			Logger.verifyEquals("200", removesellerliveCall.getString("Code"), "验证Code");
			Logger.verifyEquals(true, removesellerliveCall.getSuccess(), "验证Code");
			LiveRoom dblive = liveRoomWapper.selectLiveRoomById(createlive.getId());
			Logger.verifyEquals(-1, dblive.getAction(), "验证status");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RemoveSellerLive_006() {
		Logger.start(true,"status9已关闭直播运营端删除成功");
		try {
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
			liveRoomWapper.updateLiveRoomPushStatus(createlive.getId(), 9);
			removesellerliveBean.setLiveId(createlive.getId());
			removesellerliveBean.setUserId(createlive.getUserId());
			removesellerliveCall.setData(removesellerliveBean);
			removesellerliveCall.callService();			
			Logger.verifyEquals("200", removesellerliveCall.getString("Code"), "验证Code");
			Logger.verifyEquals(true, removesellerliveCall.getSuccess(), "验证Code");
			LiveRoom dblive = liveRoomWapper.selectLiveRoomById(createlive.getId());
			Logger.verifyEquals(-1, dblive.getAction(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RemoveSellerLive_007() {
		Logger.start(true,"status10已关闭直播运营端删除成功");
		try {
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
			liveRoomWapper.updateLiveRoomPushStatus(createlive.getId(), 10);
			removesellerliveBean.setLiveId(createlive.getId());
			removesellerliveBean.setUserId(createlive.getUserId());
			removesellerliveCall.setData(removesellerliveBean);
			removesellerliveCall.callService();			
			Logger.verifyEquals("200", removesellerliveCall.getString("Code"), "验证Code");
			Logger.verifyEquals(true, removesellerliveCall.getSuccess(), "验证Code");
			LiveRoom dblive = liveRoomWapper.selectLiveRoomById(createlive.getId());
			Logger.verifyEquals(-1, dblive.getAction(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RemoveSellerLive_008() {
		Logger.start(true,"status0直播未开始删除失败");
		try {
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
			removesellerliveBean.setLiveId(createlive.getId());
			removesellerliveBean.setUserId(createlive.getUserId());
			removesellerliveCall.setData(removesellerliveBean);
			removesellerliveCall.callService();			
			Logger.verifyEquals("201", removesellerliveCall.getString("Code"), "验证Code");
			Logger.verifyIsContains("无法删除", removesellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RemoveSellerLive_009() {
		Logger.start(true,"status2直播推流删除失败");
		try {
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
			LiveRoomCallService.SellerLiveOnline(createlive.getId(),createlive.getUserId());
			removesellerliveBean.setLiveId(createlive.getId());
			removesellerliveBean.setUserId(createlive.getUserId());
			removesellerliveCall.setData(removesellerliveBean);
			removesellerliveCall.callService();			
			Logger.verifyEquals("201", removesellerliveCall.getString("Code"), "验证Code");
			Logger.verifyIsContains("无法删除", removesellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RemoveSellerLive_010() {
		Logger.start(true,"status3直播断流删除失败");
		try {
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
			LiveRoomCallService.SellerLiveOnline(createlive.getId(),createlive.getUserId());
			liveRoomWapper.updateLiveRoomPushStatus(createlive.getId(), 3);
			removesellerliveBean.setLiveId(createlive.getId());
			removesellerliveBean.setUserId(createlive.getUserId());
			removesellerliveCall.setData(removesellerliveBean);
			removesellerliveCall.callService();			
			Logger.verifyEquals("201", removesellerliveCall.getString("Code"), "验证Code");
			Logger.verifyIsContains("无法删除", removesellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}